package owg.util.opengl;

import owg.util.euclidian.Compass;

public interface GLFont
{
	public static interface ColorProducer
	{
		/**Gets the color for a character. A color of null indicates no change. The first color (line 0, character 0) should be non-null.*/
		ColorF getColor(CharSequence str, int lineNumber, int charPos);
	}
	public static class PlainColor implements ColorProducer
	{
		private ColorF color;
		public PlainColor(ColorF color)
		{
			this.color = color;
		}
		@Override
		public ColorF getColor(CharSequence str, int lineNumber, int charPos)
		{
			if(charPos == 0)
				return color;
			return null;
		}
		
	}
	
	
	float getStringWidth(String title);
	float getStringHeight(String title);
	
	public void setColorProducer(ColorProducer color);
	
	/**Set the color which will be used for rendering.
	 * Using this method implies constant-color rendering,
	 * equivalent to setting the ColorProducer to a PlainColor instance.*/
	public default void setColor(ColorF color)
	{
		setColorProducer(new PlainColor(color));
	}
	
	/**Draw the text oriented around the given position, with a maximum width.
	 * Any line that is too long will be abbreviated, and a set of ellipsis
	 * will be appended(if there is enough space for them).
	 * <b>This method will render the text to the current framebuffer immediately,
	 * as a single batch. Begin/end calls are handled internally.</b>
	 * <br/><br/>
	 * If multi-line text should be rendered, then a newline character '\n' 
	 * should be used between each line.
	 * <b>Note that this method will never add new line breaks.</b>
	 * <br/><br/>
	 * The orientation specifies the text origin. For example, WEST indicates
	 * that the horizontal alignment should be left and the vertical alignment
	 * should be middle. SOUTHEAST indicates bottom-right alignment.
	 * */
	void renderConstrained(EGL<?> egl, String text, int x, int y, Compass orientation, int maxWidth);
	/**Draw the text oriented around the given position.
	 * <b>This method will render the text to the current framebuffer immediately,
	 * as a single batch. Begin/end calls are handled internally.</b>
	 * <br/><br/>
	 * If multi-line text should be rendered, then a newline character '\n' 
	 * should be used between each line.
	 * <br/><br/>
	 * The orientation specifies the text origin. For example, WEST indicates
	 * that the horizontal alignment should be left and the vertical alignment
	 * should be middle. SOUTHEAST indicates bottom-right alignment.
	 * */
	void render(EGL<?> egl, String text, int x, int y, Compass orientation);
	/**Draw the text oriented around the given position.
	 * <b>This method will render the text to the current framebuffer immediately,
	 * as a single batch. Begin/end calls are handled internally.</b>
	 * <br/><br/>
	 * Each element in the array constitutes a line, and should not contain newline characters.
	 * <br/><br/>
	 * The orientation specifies the text origin. For example, WEST indicates
	 * that the horizontal alignment should be left and the vertical alignment
	 * should be middle. SOUTHEAST indicates bottom-right alignment.
	 * */
	void render(EGL<?> egl, String[] text, int x, int y, Compass orientation);
	/**Get the height of a line, in pixels.*/
	float getLineHeight();
	/**Get the width of the indicated char, in pixels.*/
	float getCharWidth(char c);
	/**Get the "point size" of the font. A meaningless metric.*/
	int getSize();
}
